﻿<%@ Page Title="" Language="C#"  AutoEventWireup="true" CodeBehind="Announcement.aspx.cs" Inherits="mojoPortal.Web.RS.SBM.Telerik.Announcement" %>

<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<%@ Register TagPrefix="scheduler" TagName="AnnouncementForm" Src="Template/AnnouncementForm.ascx" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/tr/xhtml11/dtd/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
	<style type="text/css">
		.RadScheduler .rsAdvancedEdit .RadColorPicker label
		{
			text-align: left;
			display: block;
			padding: 0;
		}
	</style>
	<telerik:RadStyleSheetManager ID="RadStyleSheetManager1" runat="server" />
</head>
<body class="BODY">
	<form id="Form1" method="post" runat="server">
	<telerik:RadScriptManager ID="RadScriptManager1" runat="server">
		<Scripts>
			<asp:ScriptReference Path="~/RS/SBM/Components/Telerik/Template/AdvancedForm.js" />
			<%--Needed for JavaScript IntelliSense in VS2010--%>
			<%--For VS2008 replace RadScriptManager with ScriptManager--%>
			<asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
		</Scripts>
	</telerik:RadScriptManager>
	<script type="text/javascript">	
		//<![CDATA[

	    // Dictionary containing the advanced template client object
	    // for a given RadScheduler instance (the control ID is used as key).
	    var schedulerTemplates = {};

	    function schedulerFormCreated(scheduler, eventArgs) {
	        // Create a client-side object only for the advanced templates
	        var mode = eventArgs.get_mode();
	        if (mode == Telerik.Web.UI.AnnouncementFormMode.AdvancedInsert ||
					mode == Telerik.Web.UI.AnnouncementFormMode.AdvancedEdit) {
	            // Initialize the client-side object for the advanced form
	            var formElement = eventArgs.get_formElement();
	            var templateKey = scheduler.get_id() + "_" + mode;
	            var advancedTemplate = schedulerTemplates[templateKey];
	            if (!advancedTemplate) {
	                // Initialize the template for this RadScheduler instance
	                // and cache it in the schedulerTemplates dictionary
	                var schedulerElement = scheduler.get_element();
	                var isModal = scheduler.get_advancedFormSettings().modal;
	                advancedTemplate = new window.SchedulerAdvancedTemplate(schedulerElement, formElement, isModal);
	                advancedTemplate.initialize();

	                schedulerTemplates[templateKey] = advancedTemplate;

	                // Remove the template object from the dictionary on dispose.
	                scheduler.add_disposing(function () {
	                    schedulerTemplates[templateKey] = null;
	                });
	            }

	            // Are we using Web Service data binding?
	            if (!scheduler.get_webServiceSettings().get_isEmpty()) {
	                // Populate the form with the appointment data
	                var apt = eventArgs.get_appointment();
	                var isInsert = mode == Telerik.Web.UI.AnnouncementFormMode.AdvancedInsert;
	                advancedTemplate.populate(apt, isInsert);
	            }
	        }
	    }	
		//]]>
	</script>


	<telerik:RadScheduler runat="server" ID="RadScheduler1" AppointmentStyleMode="Default"
        DayStartTime="08:00:00" DayEndTime="18:00:00" EnableExactTimeRendering="true"
        Localization-AdvancedNewAppointment="New Announcement" Localization-AdvancedEditAppointment="Edit Announcement" 
        ShowViewTabs="true" SelectedView="MonthView" OverflowBehavior="Expand" StartEditingInAdvancedForm="true" StartInsertingInAdvancedForm="true" ShowAllDayRow="true"
		OnAppointmentDataBound="RadScheduler1_AnnouncementDataBound" OnClientFormCreated="schedulerFormCreated"
		EnableDescriptionField="True" TimeZoneOffset="2:00" DataDescriptionField="Description" DataEndField="End" DataKeyField="AnnouncementID"
		DataRecurrenceField="RecurrenceRule" TimeZoneID="FLE Standard Time" DataRecurrenceParentKeyField="RecurrenceParentID"
		DataReminderField="Reminder" DataSourceID="SqlDataSource1" DataStartField="Start"
		DataTimeZoneIdField="TimeZoneID" DataSubjectField="Subject" OnFormCreated="RadScheduler1_FormCreated"
        Height="100%" Width="100%" CustomAttributeNames="Location">
        <TimelineView UserSelectable="false"/>
        <MultiDayView UserSelectable="false" />
        <DayView UserSelectable="true" />
        <WeekView UserSelectable="true" />
        <MonthView UserSelectable="true" />
 <%--       <ResourceTypes>
            <telerik:ResourceType KeyField="AssignTo" Name="AssignTo" TextField="AssignTo" ForeignKeyField="AssignTo" DataSourceID="AssignToDataSource" />
        </ResourceTypes>--%>
		<AdvancedForm Modal="true" Width="100%" />
		<Reminders Enabled="true" />
		<AdvancedEditTemplate>
			<scheduler:AnnouncementForm runat="server" ID="AdvancedEditForm1" Mode="Edit" Subject='<%# Bind("Subject") %>'
				Description='<%# Bind("Description") %>' Start='<%# Bind("Start") %>' End='<%# Bind("End") %>'
				RecurrenceRuleText='<%# Bind("RecurrenceRule") %>' Reminder='<%# Bind("Reminder") %>' Location='<%# Bind("Location") %>' />
		</AdvancedEditTemplate>
		<AdvancedInsertTemplate>
			<scheduler:AnnouncementForm runat="server" ID="AdvancedInsertForm1"  Mode="Insert" Subject='<%# Bind("Subject") %>'
				Start='<%# Bind("Start") %>' End='<%# Bind("End") %>' Description='<%# Bind("Description") %>'
				RecurrenceRuleText='<%# Bind("RecurrenceRule") %>' Reminder='<%# Bind("Reminder") %>' Location='<%# Bind("Location") %>' />
		</AdvancedInsertTemplate>
<%--		<ResourceTypes>
			<telerik:ResourceType DataSourceID="SqlDataSource2" ForeignKeyField="TeacherID" KeyField="TeacherID"
				Name="Teacher" TextField="Name" />
		</ResourceTypes>--%>
		<TimeSlotContextMenuSettings EnableDefault="true" />
		<AppointmentContextMenuSettings EnableDefault="true" />
	</telerik:RadScheduler>
<%--	<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:ReadyServiceConnectionString %>"
		SelectCommand="SELECT * FROM [DbProvider_Teachers]"></asp:SqlDataSource>--%>
	<asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        OnInit="SqlDataSource1_OnInit"
        SelectCommand="SELECT * FROM [rs_tblAnnouncement] WHERE CompanyID=@CompanyID " 
        UpdateCommand="UPDATE [rs_tblAnnouncement] SET [Subject] = @Subject, [Start] = @Start, [End] = @End, [RecurrenceRule] = @RecurrenceRule, [RecurrenceParentID] = @RecurrenceParentID, [Reminder] = @Reminder, [Description] = @Description, [Location] = @Location WHERE [AnnouncementID] = @AnnouncementID AND [CompanyID] = @CompanyID"
        DeleteCommand="DELETE FROM [rs_tblAnnouncement] WHERE [AnnouncementID] = @AnnouncementID AND CompanyID=@CompanyID " 
        InsertCommand="INSERT INTO [rs_tblAnnouncement] ([Subject], [Start], [End], [RecurrenceRule], [RecurrenceParentID], [Reminder], [Description], [Location], [CompanyID]) 
			VALUES (@Subject, @Start, @End, @RecurrenceRule, @RecurrenceParentID, @Reminder, @Description, @Location, @CompanyID)">
        <SelectParameters>
            <asp:SessionParameter Name="CompanyID" SessionField="CompanyID" />
        </SelectParameters>
		<DeleteParameters>
			<asp:Parameter Name="AnnouncementID" Type="Int32" />
            <asp:SessionParameter Name="CompanyID" SessionField="CompanyID" />
		</DeleteParameters>
		<InsertParameters>
			<asp:Parameter Name="Subject" Type="String" />
			<asp:Parameter Name="Start" Type="DateTime" />
			<asp:Parameter Name="End" Type="DateTime" />
			<asp:Parameter Name="RecurrenceRule" Type="String" />
			<asp:Parameter Name="RecurrenceParentID" Type="Int32" />
			<asp:Parameter Name="Reminder" Type="String" />
			<asp:Parameter Name="Description" Type="String" />
            <asp:Parameter Name="Location" Type="String" />
            <asp:SessionParameter Name="CompanyID" SessionField="CompanyID" />
		</InsertParameters>
		<UpdateParameters>
			<asp:Parameter Name="Subject" Type="String" />
			<asp:Parameter Name="Start" Type="DateTime" />
			<asp:Parameter Name="End" Type="DateTime" />
			<asp:Parameter Name="RecurrenceRule" Type="String" />
			<asp:Parameter Name="RecurrenceParentID" Type="Int32" />
			<asp:Parameter Name="Reminder" Type="String" />
			<asp:Parameter Name="Description" Type="String" />
            <asp:Parameter Name="Location" Type="String" />
			<asp:Parameter Name="AnnouncementID" Type="Int32" />
            <asp:SessionParameter Name="CompanyID" SessionField="CompanyID" />
		</UpdateParameters>
	</asp:SqlDataSource>
	</form>
</body>
</html>
